﻿using System.Drawing;
using GLWrap;
using ReAnimation.Domain;
using ReAnimation.Helpers.Drawing;
using Sharp3D.Math.Core;

namespace ReAnimation.Graphics
{
    internal class MaterialFactory
    {
        private readonly float DefaultShininess = 75;

        public Material CreateMaterialForAtom(Atom atom)
        {
            return CreateMaterial(atom.AtomDescription.Color, DefaultShininess);
        }

        public Material CreateMaterial(Color color)
        {
            return CreateMaterial(color, DefaultShininess);
        }

        public Material CreateMaterial(Color color, float shininess)
        {
            var material = new Material
            {
                Ambient = new Vector4F(0, 0, 0, 1),
                Diffuse = new Vector4F(color.GetFloatColors()[0],
                                       color.GetFloatColors()[1],
                                       color.GetFloatColors()[2],
                                       1.0f),
                Specular = new Vector4F(1, 1, 1, 1),
                Shininess = shininess
            };
            material.Emission = material.Diffuse / 5;
            return material;
        }
    }
}
